package com.example.bawolf.web.controller;

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @author zhougf
 * @version 1.0
 * @date 2020/06/03
 */
public class Test {

    public static void main(String[] args) throws ParseException {
        ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
        taskExecutor.setCorePoolSize(10);
        taskExecutor.setMaxPoolSize(20);
        taskExecutor.setQueueCapacity(15);
        taskExecutor.setAllowCoreThreadTimeOut(true);
        taskExecutor.setKeepAliveSeconds(60);
        taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        taskExecutor.initialize();
       List<Integer> stringList = Arrays.asList(6, 7, 8);
       for(int i = 0; i < 40; i++) {
           int j = i;
           taskExecutor.execute(new Runnable() {
               @Override
               public void run() {
                   System.out.println((j % 3) + ":" + LocalDate.of(2020,9, stringList.get(j % 3)));
               }
           });
       }

    }
}
